package com.example.mina.demo1;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.service.IoHandler;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.filter.codec.textline.TextLineEncoder;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;

public class MInaTestServer {
    public static void main(String[] args) throws IOException {
        // 创建一个NioSocketAcceptor对象
        IoAcceptor acceptor = new NioSocketAcceptor();
        // 添加一个编码过滤器，将文本行编码为UTF-8
        acceptor.getFilterChain().addLast("codec",new ProtocolCodecFilter(new TextLineCodecFactory(
                Charset.forName("UTF-8")
        )));

        // 添加一个日志过滤器
        acceptor.getFilterChain().addLast("logger",new LoggingFilter());

        // 设置处理器为null
        acceptor.setHandler(null);
        // 绑定到8080端口
        acceptor.bind(new InetSocketAddress(8888));
    }
}


class MyIoHandler implements IoHandler {


}

